<?php
/**
 * ============================================================================
 * email: ngj6666@126.com
 * url: http://aacms.net
 * ============================================================================
*/

class memcache
{
	var $enable;
	var $obj;

	function memcache() {

	}

	function init($config) {
		if(!empty($config['server'])) {
			$this->obj = new Memcache;
			if($config['pconnect']) {
				$connect = @$this->obj->pconnect($config['server'], $config['port']);
			} else {
				$connect = @$this->obj->connect($config['server'], $config['port']);
			}
			$this->enable = $connect ? true : false;
		}
	}

	function get($key) {
		return $this->obj->get($key);
	}

	function set($key, $value, $ttl = 0) {
		return $this->obj->set($key, $value, MEMCACHE_COMPRESSED, $ttl);
	}

	function rm($key) {
		return $this->obj->delete($key);
	}

}

?>